﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Security.Principal;
using ASER.BusinessLogic.Security;
using ASER.DataEntity.Security;
using System.Collections.Generic;


/// <summary>
/// 用户身份标识
/// </summary>
public class ASERIdentity : System.Security.Principal.IIdentity
{

    private ArrayList m_Permits = null;
    private string userCode;
    private string userName;
    private string gender;
    private string orgCode;
    private string typeCode;
    private string pID;
    private string tel;
    private string mobileNo;
    private string email;
    private string address;
    private string zipCode;
    private DateTime regDate;
    private string isChangePwd;
    private string isForbid;

    public ASERIdentity(string userID)
    {
        using (LoginBusiness User = new LoginBusiness())
        {
            SysOperatorEntity UserInfo = User.GetUserData(userID);
            userCode = UserInfo.UserCode;
            userName = UserInfo.UserName;
            gender = UserInfo.Gender;
            orgCode = UserInfo.OrgCode;
            typeCode = UserInfo.TypeCode;
            pID = UserInfo.PID;
            tel = UserInfo.Tel;
            mobileNo = UserInfo.MobileNo;
            email = UserInfo.Email;
            address = UserInfo.Address;
            zipCode = UserInfo.ZipCode;
            regDate = UserInfo.RegDate;
            isChangePwd = UserInfo.IsChangePwd;
            isForbid = UserInfo.IsForbid;
            List<SysMenuEntity> list = User.GetUserPermits(userCode);
            foreach (SysMenuEntity menu in list)
            {
                Permits.Add(menu);
            }
        }
    }


    #region 继承成员

    public string AuthenticationType
    {
        get
        {
            return "Foms";
        }
        set
        {

        }
    }

    public bool IsAuthenticated
    {
        get
        {
            return true;
        }
    }

    public string Name
    {
        get
        {
            return userCode;
        }
    }

    #endregion

    #region 属性

    /// <summary>
    /// 用户许可集合
    /// </summary>
    public ArrayList Permits
    {
        get
        {
            if (m_Permits == null)
                m_Permits = new ArrayList();
            return m_Permits;
        }
    }

    /// <summary>
    /// 用户编码
    /// </summary>

    public string UserCode
    {
        get { return userCode; }
    }
    /// <summary>
    /// 用户姓名
    /// </summary>
    public string UserName
    {
        get { return userName; }
    }

    /// <summary>
    /// 用户性别
    /// </summary>
    public string Gender
    {
        get { return gender; }
    }

    /// <summary>
    /// 机构编码
    /// </summary>
    public string OrgCode
    {
        get { return orgCode; }
    }

    /// <summary>
    /// 类型编码
    /// </summary>
    public string TypeCode
    {
        get { return typeCode; }
    }

    /// <summary>
    /// 身份证号
    /// </summary>
    public string PID
    {
        get { return pID; }
    }

    /// <summary>
    /// 办公电话
    /// </summary>
    public string Tel
    {
        get { return tel; }

    }

    /// <summary>
    /// 手机号码
    /// </summary>
    public string MobileNo
    {
        get { return mobileNo; }
    }

    /// <summary>
    /// 电子邮件
    /// </summary>
    public string Email
    {
        get { return email; }
    }

    /// <summary>
    /// 用户地址
    /// </summary>
    public string Address
    {
        get { return address; }
    }

    /// <summary>
    /// 邮政编码
    /// </summary>
    public string ZipCode
    {
        get { return zipCode; }
    }

    /// <summary>
    /// 注册时间
    /// </summary>
    public DateTime RegDate
    {
        get { return regDate; }
    }

    /// <summary>
    /// 是否已更改密码
    /// </summary>
    public string IsChangePwd
    {
        get { return isChangePwd; }
    }

    /// <summary>
    /// 是否禁用
    /// </summary>
    public string IsForbid
    {
        get { return isForbid; }
    }

    #endregion
}